home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / SLAX 6.0.8 / slax-6.0.8.iso / slax / base / 006-devel.lzm / usr / include / kio / observer.h < prev    next >
Encoding:
C/C++ Source or Header  |  2005-10-10  |  7.2 KB  |  214 lines

  1. /* This file is part of the KDE libraries
  2.    Copyright (C) 2000 Matej Koss <koss@miesto.sk>
  3.                       David Faure <faure@kde.org>
  4.  
  5.    This library is free software; you can redistribute it and/or
  6.    modify it under the terms of the GNU Library General Public
  7.    License version 2 as published by the Free Software Foundation.
  8.  
  9.    This library is distributed in the hope that it will be useful,
  10.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  11.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  12.    Library General Public License for more details.
  13.  
  14.    You should have received a copy of the GNU Library General Public License
  15.    along with this library; see the file COPYING.LIB.  If not, write to
  16.    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  17.    Boston, MA 02110-1301, USA.
  18. */
  19. #ifndef __kio_observer_h__
  20. #define __kio_observer_h__
  21.  
  22. #include <qobject.h>
  23. #include <dcopobject.h>
  24. #include <qintdict.h>
  25.  
  26. #include <kio/global.h>
  27. #include <kio/authinfo.h>
  28. #include "kio/job.h"
  29. #include "kio/skipdlg.h"
  30. #include "kio/renamedlg.h"
  31.  
  32. class UIServer_stub;
  33. class KURL;
  34.  
  35. namespace KIO {
  36.   class Job;
  37. }
  38.  
  39. /**
  40.  * Observer for KIO::Job progress information.
  41.  *
  42.  * This class, of which there is always only one instance,
  43.  * "observes" what jobs do and forwards this information
  44.  * to the progress-info server.
  45.  *
  46.  * It is a DCOP object so that the UI server can call the
  47.  * kill method when the user presses Cancel.
  48.  *
  49.  * Usually jobs are automatically registered by the
  50.  * KIO::Scheduler, so you do not have to care about that.
  51.  *
  52.  * @short Observer for KIO::Job progress information
  53.  * @author David Faure <faure@kde.org>
  54.  */
  55. class KIO_EXPORT Observer : public QObject, public DCOPObject {
  56.  
  57.   K_DCOP
  58.   Q_OBJECT
  59.  
  60. public:
  61.  
  62.   /**
  63.    * Returns the unique observer object.
  64.    * @return the observer object
  65.    */
  66.   static Observer * self() {
  67.       if (!s_pObserver) s_pObserver = new Observer;
  68.       return s_pObserver;
  69.   }
  70.  
  71.   /**
  72.    * Called by the job constructor, to signal its presence to the
  73.    * UI Server.
  74.    * @param job the new job
  75.    * @param showProgress true to show progress, false otherwise
  76.    * @return the progress ID assigned by the UI Server to the Job.
  77.    */
  78.   int newJob( KIO::Job * job, bool showProgress );
  79.  
  80.   /**
  81.    * Called by the job destructor, to tell the UI Server that
  82.    * the job ended.
  83.    * @param progressId the progress ID of the job, as returned by newJob()
  84.    */
  85.   void jobFinished( int progressId );
  86.  
  87.   /**
  88.    * @deprecated use KIO::AutoInfo
  89.    */
  90.   bool openPassDlg( const QString& prompt, QString& user, QString& pass,
  91.                     bool readOnly );
  92.  
  93.   /**
  94.    * Opens a password dialog.
  95.    * @param info the authentication information
  96.    * @return true if successful ("ok" clicked), false otherwise
  97.    */
  98.   bool openPassDlg( KIO::AuthInfo& info );
  99.  
  100.   /**
  101.    * Popup a message box. See KIO::SlaveBase.
  102.    * This doesn't use DCOP anymore, it shows the dialog in the application's process.
  103.    * Otherwise, other apps would block when trying to communicate with UIServer.
  104.    * @param progressId the progress ID of the job, as returned by newJob()
  105.    * @param type the type of the message box
  106.    * @param text the text to show
  107.    * @param caption the window caption
  108.    * @param buttonYes the text of the "Yes" button
  109.    * @param buttonNo the text of the "No button
  110.    */
  111.   static int messageBox( int progressId, int type, const QString &text, const QString &caption,
  112.                          const QString &buttonYes, const QString &buttonNo );
  113.  
  114.   /**
  115.    * Popup a message box. See KIO::SlaveBase.
  116.    * This doesn't use DCOP anymore, it shows the dialog in the application's process.
  117.    * Otherwise, other apps would block when trying to communicate with UIServer.
  118.    * @param progressId the progress ID of the job, as returned by newJob()
  119.    * @param type the type of the message box
  120.    * @param text the text to show
  121.    * @param caption the window caption
  122.    * @param buttonYes the text of the "Yes" button
  123.    * @param buttonNo the text of the "No button
  124.    * @param dontAskAgainName A checkbox is added with which further confirmation can be turned off.
  125.    *        The string is used to lookup and store the setting in kioslaverc.
  126.    * @since 3.3
  127.    */
  128.   static int messageBox( int progressId, int type, const QString &text, const QString &caption,
  129.                          const QString &buttonYes, const QString &buttonNo, const QString &dontAskAgainName );
  130.  
  131.   /**
  132.    * @internal
  133.    * See renamedlg.h
  134.    */
  135.   KIO::RenameDlg_Result open_RenameDlg( KIO::Job * job,
  136.                                         const QString & caption,
  137.                                         const QString& src, const QString & dest,
  138.                                         KIO::RenameDlg_Mode mode,
  139.                                         QString& newDest,
  140.                                         KIO::filesize_t sizeSrc = (KIO::filesize_t) -1,
  141.                                         KIO::filesize_t sizeDest = (KIO::filesize_t) -1,
  142.                                         time_t ctimeSrc = (time_t) -1,
  143.                                         time_t ctimeDest = (time_t) -1,
  144.                                         time_t mtimeSrc = (time_t) -1,
  145.                                         time_t mtimeDest = (time_t) -1
  146.                                         );
  147.  
  148.   /**
  149.    * @internal
  150.    * See skipdlg.h
  151.    */
  152.   KIO::SkipDlg_Result open_SkipDlg( KIO::Job * job,
  153.                                     bool multi,
  154.                                     const QString & error_text );
  155.  
  156. k_dcop:
  157.   /**
  158.    * Called by the UI Server (using DCOP) if the user presses cancel.
  159.    * @param progressId the progress ID of the job, as returned by newJob()
  160.    */
  161.   void killJob( int progressId );
  162.  
  163.   /**
  164.    * Called by the UI Server (using DCOP) to get all the metadata of the job
  165.    * @param progressId the progress IDof the job, as returned by newJob()
  166.    */
  167.   KIO::MetaData metadata( int progressId );
  168.  
  169. protected:
  170.  
  171.   static Observer * s_pObserver;
  172.   Observer();
  173.   ~Observer() {}
  174.  
  175.   UIServer_stub * m_uiserver;
  176.  
  177.   QIntDict< KIO::Job > m_dctJobs;
  178.  
  179. public slots:
  180.  
  181.   void slotTotalSize( KIO::Job*, KIO::filesize_t size );
  182.   void slotTotalFiles( KIO::Job*, unsigned long files );
  183.   void slotTotalDirs( KIO::Job*, unsigned long dirs );
  184.  
  185.   void slotProcessedSize( KIO::Job*, KIO::filesize_t size );
  186.   void slotProcessedFiles( KIO::Job*, unsigned long files );
  187.   void slotProcessedDirs( KIO::Job*, unsigned long dirs );
  188.  
  189.   void slotSpeed( KIO::Job*, unsigned long speed );
  190.   void slotPercent( KIO::Job*, unsigned long percent );
  191.   void slotInfoMessage( KIO::Job*, const QString & msg );
  192.  
  193.   void slotCopying( KIO::Job*, const KURL& from, const KURL& to );
  194.   void slotMoving( KIO::Job*, const KURL& from, const KURL& to );
  195.   void slotDeleting( KIO::Job*, const KURL& url );
  196.   /// @since 3.1
  197.   void slotTransferring( KIO::Job*, const KURL& url );
  198.   void slotCreatingDir( KIO::Job*, const KURL& dir );
  199.   // currently unused
  200.   void slotCanResume( KIO::Job*, KIO::filesize_t offset );
  201.  
  202. public:
  203.   void stating( KIO::Job*, const KURL& url );
  204.   void mounting( KIO::Job*, const QString & dev, const QString & point );
  205.   void unmounting( KIO::Job*, const QString & point );
  206. protected:
  207.   virtual void virtual_hook( int id, void* data );
  208. private:
  209.   class ObserverPrivate* d;
  210. };
  211.  
  212. // -*- mode: c++; c-basic-offset: 2 -*-
  213. #endif
  214.